<!--
* description: 今日待分配线索
* author: mwh
* createdDate: 2010-11-21
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamicButtons="tableButtons"
      :dynamicComponents="tableComponents"
      :dynamicApiConfig="apiConfig"
      :dynamicTableCols="tableCols"
      :dynamicFormFields="formField"
      :dynamicIsShowSelect="isMul"
      :dynamicIsShowMoreBtn="true"
    />
    <ClueMenuAssign
      ref="clueMenu"
      :dynamicEditRowData="clueAssignRowData"
      :dynamicIsShowSelect="isMul"
      :popupsVisible="clueAssignPopupsVisible"
      :key="clueAssignPopupsKey"
      :popupsState="clueAssignPopupsState"
      @close="closClueAssign"
    />
  </div>
</template>
<script>
import { crmApis } from "@/api/apiList/crm.js";
import { requestGraphQL } from "@/api/commonRequest";
import OneTableTemplate from "@/components/crm/Template/crmonePage";
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import ClueMenuAssign from "./crmThisGWACCDPeopage";

export default {
  name: "crmThisGWACCDistrpage",
  // 组件混入对象
  mixins: [oneTableWithViewTemplateMixins],
  components: {
    OneTableTemplate,
    ClueMenuAssign
  },
  data() {
    return {
      serverOrderArray: [],
      clueAssignRowData:{},
      isMul:"",
      clueAssignPopupsState:"",
      clueAssignPopupsKey:"clueAssignPopupsKey",
      clueAssignPopupsVisible: false,
      multipleSelection: [],
      clueScriptNumber: [],
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "",
          size: "small",
          clickEvent: () => this.clueAssign(),
          text: "线索分配",
          isMust: true
        },
        {
          compKey: "btnKey2",
          type: "",
          size: "small",
          clickEvent: () =>
            this.exportExcel("本组待办任务分配_线索培育.xlsx", "Sheet1", 999999),
          text: "导出",
          isMust: true
        }
      ],
      // 动态组件-查询条件
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
              .tableComponents
          : [
              {
                compKey: "compKey1",
                labelName: "客户名称",
                codeField: "custName",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey2",
                labelName: "电话",
                codeField: "contactTel",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey3",
                labelName: "车辆品牌",
                codeField: "carBrandCode",
                textField: "carBrandCn",
                lookuptype: crmApis.mdmCarBrandQueryByPage, //API或者值列表编码
                component: () =>
                  import("@/components/crm/lookupValue/apiDropList"), //导入的组件路径
                type: "dropdownlist",
                isMust: false
              },
              {
                compKey: "compKey4",
                labelName: "线索单号",
                codeField: "serverOrder",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey5",
                labelName: "建单日期",
                codeField: "createdDateStart,createdDateEnd",
                component: () =>
                  import("@/components/crm/Time/crmdtDatePicker"),
                type: "date",
                isMust: false
              },

              {
                compKey: "compKey6",
                labelName: "批次号",
                codeField: "batchNo",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey7",
                labelName: "外呼次数",
                codeField: "outboundQty",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey8",
                labelName: "当前处理人",
                codeField: "nextDealUserName",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey9",
                labelName: "留资时间",
                codeField: "remainDataDateStart,remainDataDateEnd",
                component: () =>
                  import("@/components/crm/Time/crmdtDatePicker"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey10",
                labelName: "接触方式",
                codeField: "cantactWayCode",
                textField: "cantactWayName",
                lookuptype: crmApis.pcDbCantactWayQueryFindAll,
                component: () =>
                  import("@/components/crm/lookupValue/singleDropList"),
                type: "dropdownList",
                isMust: false,
                isMul: false
              },
              {
                compKey: "cantactWayCode",
                labelName: "渠道大类",
                codeField: "infoChanMCode",
                textField: "infoChanMName",
                lookuptype: crmApis.pcDbInfoChanMQueryFind,
                changeCodeArray: [{ changCode: "cantactWayCode" }],
                component: () =>
                  import("@/components/crm/lookupValue/secondDropList"), //导入的组件路径
                type: "dropdownList",
                isMust: false,
                isMul: false
              },
              {
                compKey: "compKey12",
                labelName: "渠道小类名称",
                codeField: "infoChanDName",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: false
              },
              // {
              //   compKey: "infoChanMCode",
              //   labelName: "渠道小类",
              //   codeField: "infoChanDCode",
              //   textField: "infoChanDName",
              //   lookuptype: crmApis.pcDbInfoChanDQueryFind,
              //   changeCodeArray: [{ changCode: "infoChanMCode" }],
              //   extralParams: { oemCode: "1", groupCode: "1", isPv: "1" }, //参数
              //   component: () =>
              //     import("@/components/crm/lookupValue/secondDropList"), //导入的组件路径
              //   type: "dropdownList",
              //   isMust: false,
              //   isMul: false
              // },
              {
                compKey: "compKey13",
                labelName: "分配状态",
                lookuptype: "SE0068",
                codeField: "assignStatus",
                component: () => import("@/components/org/LookupValue"),
                type: "inputText",
                isMust: false
              }
            ],

      // 动态生成网格列
      apiConfig: crmApis.clueServerQueryFromHeadquarters,
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
              {
                prop: "nextDealUserName",
                label: "当前处理人",
                width: 120,
                align: "center",
                fixed: true
              },
              {
                prop: "carBrandName",
                label: "车辆品牌",
                width: 150,
                align: "center",
                fixed: true
              },
              {
                prop: "batchNo",
                label: "批次号",
                width: 120,
                align: "center",
                fixed: true
              },
              {
                prop: "serverOrder",
                label: "线索单号",
                width: 200,
                align: "center"
              },
              {
                prop: "custName",
                label: "客户名称",
                width: 120,
                align: "center"
              },
              {
                prop: "contactTel",
                label: "电话",
                width: 120,
                align: "center"
              },
              {
                prop: "carSeriesCn",
                label: "意向车系",
                width: 150,
                align: "center"
              },
              {
                prop: "cantactWayName",
                label: "接触方式",
                width: 120,
                align: "center"
              },
              {
                prop: "infoChanMName",
                label: "渠道大类",
                width: 120,
                align: "center"
              },
              {
                prop: "infoChanDName",
                label: "渠道小类名称",
                width: 120,
                align: "center"
              },
              {
                prop: "cleanQty",
                label: "接触次数",
                width: 100,
                align: "center"
              },
              {
                prop: "createdName",
                label: "建单人",
                width: 120,
                align: "center"
              },
              {
                prop: "createdDate",
                label: "建单日期",
                width: 150,
                align: "center"
              },
              {
                prop: "assignPersonDate",
                label: "分配时间",
                width: 150,
                align: "center"
              },
              {
                prop: "assignStatusName",
                label: "分配状态",
                width: 120,
                align: "center"
              },
              {
                prop: "outboundQty",
                label: "外呼次数",
                width: 100,
                align: "center"
              },
              {
                prop: "remainDataDate",
                label: "留资时间",
                width: 150,
                align: "center"
              },
              {
                prop: "dlrCode",
                label: "专营店编码",
                width: null,
                align: "center",
                hidden: true
              }
            ],
      //是否显示table下面的组件
      isShowComponent: false,
      //表单查询数据
      formField: {
        handleCode: "1",
        statusArray: ["1", "3", "4"],
        custName: "",
        contactTel: "",
        carBrandCode: "",
        serverOrder: "",
        createdDateStart: "",
        createdDateEnd: "",
        batchNo: "",
        outboundQty: "",
        nextDealUserName: "",
        remainDataDateStart: "",
        remainDataDateEnd: "",
        cantactWayCode: "",
        infoChanMCode: "",
        infoChanDName: "",
        assignStatus: "",
        infoChanDCode: ""
      }
    };
  },
  methods: {
    closClueAssign(){

    },
    /**
     * @clueAssign：线索分配弹窗
     * 拿到选择行的单号集合
     *
     */
    clueAssign() {
      let that = this;
      debugger
      let multipleSelection = this.$refs.multipleTable.multipleSelection; //表格数组
      if (multipleSelection == null||multipleSelection.length==0) {
        this.$alert("请至少选择一条线索", "提示");
        return;
      }
      let serverOrderArray = []; //存放服务单号集合
      for (let i = 0; i < multipleSelection.length; i++) {
        serverOrderArray[i] = multipleSelection[i].serverOrder;
      }
      this.$refs.clueMenu.serverOrderArray = serverOrderArray; //将数组传给弹窗的的变量中
      that.$refs.clueMenu.curPopupsVisible = true;
      //that.$refs.clueMenu.initQueryEmployeeInfo();
    }
  }
};
</script>
